﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.PresentationModel.ViewModels;
using YasharEl.Infrastructure.PresentationModel.Views;
using System.Diagnostics.Contracts;
using System.ComponentModel;

namespace YasharEl.Infrastructure.PresentationModel.Shell
{
    public class ShellViewModel : ViewModelBase , IShell
    {
        #region Fields

        private readonly IShellView shellView;

        #endregion

        #region Constructors

        public ShellViewModel(IShellView shellView, string title)
        {
            Contract.Requires<ArgumentNullException>(shellView != null, "shellView could not be null.");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(title), "title could not be null or empty.");

            this.shellView = shellView;
            Title = title;
        }

        #endregion

        #region IShell Members

        [Description("A name displayed as a title.")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        string IShell.Title
        {
            get
            {
                return Title != null ? Title.ToString() : null;
            }
            set
            {
                Title = value;
            }
        }

        #endregion

        #region IViewTracking Members

        public IView ActiveView
        {
            get { return shellView.ActiveView; }
        }

        public IView MainView
        {
            get { return shellView.MainView; }
        }

        #endregion
    }
}
